<?php
// required
	if(defined('ROOT_PATH')) die('No permission.');
	if(!isset($_POST['p'])) die('No permission.');
	require '../../../kernel/kernel.php';
	if(!isset($user) || !$user->isLoggedIn()) die('No permission.');

// init module
	include $modules->controller();
	include $modules->lang();
	$modules->init();

// check vars
	foreach($_POST as $k => $v) {
		if(strpos($k, 'sort_') !== false) {
			
			// set vars
				$parent_id = str_replace('sort_', '', $k);
				$children = split(',', $v);
				$weight = 0;
			
			// loop children
				foreach($children as $k => $child_id) {
					
					// add weight
						$weight += 10;
					
					// save navs
						$sql = "UPDATE ".$db->module('pages_nav')." SET parent_id='".$parent_id."', weight='".$weight."' WHERE id='".$child_id."'";
						@mysql_query($sql) or die($lang->get('nav-save-failed'));
					
				}
			
		}
	}

// return success
	$lang->put('nav-save-success');


?>